﻿using System;
using System.Collections.Generic;
using DDDSample.Domain.Cargo;

namespace DDDSample.UI.Mvc.Models
{
    public class CargoViewModel
    {
        public CargoViewModel()
        { }

        public CargoViewModel(Cargo cargo)
        {
            Id = cargo.Id;
            Origin = cargo.RouteSpecification.Origin.UnLocode.CodeString;
            Destination = cargo.RouteSpecification.Destination.UnLocode.CodeString;
            ArrivalDeadline = cargo.RouteSpecification.ArrivalDeadline;
            Misrouted = cargo.Delivery.RoutingStatus == RoutingStatus.Misrouted;
            Legs = cargo.Itinerary.Legs;
        }


        public bool IsRouted
        {
            get { return Legs != null && Legs.Count > 0; }
        }

        public Guid Id { get; set; }

        public string Origin { get; set; }

        public bool Misrouted { get; set; }

        public IList<Leg> Legs { get; set; }

        public string TrackingId { get; set; }

        public string Destination { get; set; }

        public DateTime ArrivalDeadline { get; set; }
    }
}